package cn.mrcode.fd.blog.buutil;

import cn.mrcode.fd.blog.task.CacheAutoScanTask;

/**
 * 文件路径生成
 * @author : zhuqiang
 * @version : V1.0
 * @date : 2016/1/31 16:46
 */
public class FilePathUtil {
    /** 图片名称：博客秀 */
    public static final String IMG_BLOG_SHOW= "blog_show.png";
    /** 图片名称：个人头像 */
    public static final String IMG_HEAD_IMG= "head_img.png";
    /**
     * 生成 图片存储路径
     * @param imgName 固定的图片名称
     * @param account 图片所属账户
     * @return
     */
    public static ImgPathInfo generImgPathInfo(String imgName,String account){
        String rootPath = CacheAutoScanTask.getValue("res_path_abs_img", "root"); //根路径
        String baseUrl = "/depots/" + account + "/"; //物理磁盘的基础路径
        String baseDbUrl = "/assets/img" + baseUrl + imgName;  //数据库中图片访问路径

        ImgPathInfo imgPathInfo = new ImgPathInfo();
        imgPathInfo.setAbsFolderPath(rootPath +baseUrl);
        imgPathInfo.setImgName(imgName);
        imgPathInfo.setRelDbImgPath(baseDbUrl);
        return imgPathInfo;
    }

    /**
     * 文章路径
     * @param imgName
     * @param account
     * @return
     */
    public static ImgPathInfo generImgPathArticleInfo(String imgName,String account){
        String rootPath = CacheAutoScanTask.getValue("res_path_abs_img", "root"); //根路径
        String baseUrl = "/depots/" + account + "/artile/"; //物理磁盘的基础路径
        String baseDbUrl = "/assets/img" + baseUrl + imgName;  //数据库中图片访问路径

        ImgPathInfo imgPathInfo = new ImgPathInfo();
        imgPathInfo.setAbsFolderPath(rootPath +baseUrl);
        imgPathInfo.setImgName(imgName);
        imgPathInfo.setRelDbImgPath(baseDbUrl);
        return imgPathInfo;
    }
}
